<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <!-- 1、对象原型__proto__ -->
    <script>
        function Person(name, age) {
            this.name = name
            this.age = age
            Person.prototype.eat = function () {
                console.log('我会做饭');
            }
        }
        var tb = new Person("托比", 250);
        var bl = new Person("布朗", 2);
        tb.eat();
        console.log(tb);
        console.log(tb.__proto__ === Person.prototype);
    </script>
    <!-- 2、constructor构造函数 -->
    <script>
        function Person(name, age) {
            this.name = name;
            this.age = age;
        }
        
        Person.prototype = {
            constructor: Person,
            cooking: function () {
                console.log('我会做饭');
            },
            sing: function () {
                console.log('我会跳舞');
            }
        }
        var tb = new Person("托比", 250);
        var bl = new Person("布朗", 2);
        console.log(Person.prototype);
        console.log(tb.__proto__);
        console.log(Person.prototype.constructor);
        console.log(bl.__proto__.constructor);
    </script>
    
    <script>
        function Person(name, age) {
            this.name = name
            this.age = age
        }
        Person.prototype.cooking = function () {
            console.log('我会做饭');
        }
        var tb = new Person("托比", 250);
        console.log(Person.prototype);
        console.log(Person.prototype.__proto__===Object.prototype);
        console.log(Object.prototype.__proto__);
    </script>
</body>

</html>